Split Button
Volume Number: 7
Issue Number: 6
Column Tag: HyperChat
Splitting Your Sides 
By Carl J. Manaster, Globe, AZ
Note: Source code files accompanying article are located on MacTech CD-ROM orsource code disks.
[Carl is a mining engineer and programmer whose appreciation for
environments such as HyperCard and THINK Pascal is enhanced by painful memories of
dBase and FORTRAN.]
Objectives
It’s endemic among HyperCard fans to try to “fill in” the gaps left by Apple.
Such supplements often take the form of XCMDs and XFCNs, offering everything from
standard file calls to color windows. Occasionally, the purists among us like to write
these extensions in HyperTalk itself, keeping it “all in the family,” as it were. (Also,
having once used TCL or MacApp, it’s hard to imagine going back to writing Pascal
without such crutches - and they don’t help with code resources!)
One thing missing from HyperCard is polygonal buttons - arbitrary shapes that
behave like a button. The need for these has been apparent since the first release and
its Clip Art stack, where the user clicks on certain parts of the pictures to travel to
related cards. Since it’s all done with transparent (rectangular) buttons, there’s a
great deal of “slop” space, where a click that ought to be on a hat (for instance) is
really in the rectangle of the man.
There are doubtless XCMDs available that solve this problem, and I’ve seen at
least one article describing a HyperTalk-based solution; here is another.
The Basic Solution
My solution is to place buttons over each side of the polygon, and split the
message chain along each button’s diagonal. The message to do this is in the stack’s
script:
--1
--message split
--syntax: split(orientation,
----------------topMessage,bottomMessage)
--where: orientation is "/" or
--topMessage is message to be called if click
------------------was in top half of target
--bottomMessage is message to be called if click
--------------------was in bottom half of target
on split
put param(2) into topMessage
put param(3) into bottomMessage
put (the bottom of the target) -
(the clickV) into vDiff
if param(1) is "/
then put (the clickH) - (the left of
the target) into hDiff
else put (the right of the target) -
(the clickH) into hDiff
put vDiff * (the width of the target)
> hDiff * (the height of the target)
into doTop
if doTop
then send topMessage to target
else send bottomMessage to target
end split
Each button’s mouseUp script calls split with the appropriate orientation and